/**
 * 
 */
package main;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import tcpVerwaltung.TCPverbindung;
import verwaltung.Model;
import verwaltung.VerwProduktnamen;
import view.Grundbild;
import view.MenueLinks;
import controller.ContMenue;

/**
 * 
 * 
 * @date 03.08.2012
 * @author rs
 * @version
 * 
 */
public class Main {

	@SuppressWarnings("unused")
	private TCPverbindung tcpVerbindung;

	private Model model;
	private VerwProduktnamen verwProduktnamen;

	private ContMenue contMenue;

	private JFrame mainFrame;

	private MenueLinks pnlMenueLinks;
	private Grundbild pnlGrundbild;
	private JScrollPane scrCardLayout;

	/**
	 * Konstruktor
	 */
	public Main() {

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {

			e.printStackTrace();
		}

		// Initialisierung Models
		model = new Model();
		
		contMenue = new ContMenue(model);
		
		verwProduktnamen = new VerwProduktnamen(model);
		
		tcpVerbindung = new TCPverbindung(model);

		mainFrame = new JFrame("Robo ligne 8");
		mainFrame.getContentPane().setLayout(new BorderLayout(5, 5));
		mainFrame
				.addWindowListener(new FensterVerwaltung(mainFrame, contMenue));

		pnlMenueLinks = new MenueLinks(model, contMenue);
		pnlGrundbild = new Grundbild(model, verwProduktnamen, contMenue);

		scrCardLayout = new JScrollPane(pnlGrundbild);

		mainFrame.add(pnlMenueLinks, BorderLayout.WEST);
		mainFrame.add(scrCardLayout, BorderLayout.CENTER);

		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				mainFrame.pack();

				mainFrame.setLocationRelativeTo(null); // in der mitte

				mainFrame.setVisible(true);
			}
		});

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Main();

	}

}
